package util;

import java.util.Random;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class FabricaConexao {
	private static Integer id;
	private FabricaConexao(){
		
	}
	private static FabricaConexao fbConexao;
	private static EntityManagerFactory emf;
	
	
	public static EntityManager getEntityManager(){
		if (fbConexao == null) {
			id = new Random().nextInt();
			fbConexao = new FabricaConexao();
			emf = Persistence.createEntityManagerFactory("SysProvasWS");
		}
		
		System.out.println("Id: "+id);
		return emf.createEntityManager();
	}
}
